package com.my.controller;


import com.my.service.ShopCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@CrossOrigin("*")
@RequestMapping("/shopCart")
public class ShopCartController {

    ShopCartService shopCartService;

    @Autowired
    public void setShopCartService(ShopCartService shopCartService) {
        this.shopCartService = shopCartService;
    }

    @RequestMapping("/show")
    public String showGoods(Integer currentPage, Integer pageSize, String sort, Boolean asc, HttpServletRequest req) {
        return this.shopCartService.showGoods(currentPage, pageSize, sort, asc, req);
    }

    @RequestMapping("/add")
    public String addToShopCart(Integer goodsId, Integer num, HttpServletRequest req) {
        return this.shopCartService.addToShopCart(goodsId, num, req);
    }

    @RequestMapping("/update")
    public String updateShopCart(Integer cartId, Integer num, HttpServletRequest req) {
        return this.shopCartService.updateShopCart(cartId, num, req);
    }

    @RequestMapping("/delete")
    public String deleteFromShopCart(Integer cartId, HttpServletRequest req) {
        return this.shopCartService.deleteFromShopCart(cartId, req);
    }

}
